import pandas as pd

def yield_ratio(df, index, n):
    try:
        pre = df['close'].iloc[index] 
        nxt = df['close'].iloc[index+n]
        return ((nxt-pre)/pre).round(4)
    except:
        return 0.0